<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>运单管理</title>
  <link href="__PUBLIC__/css/admin/reset.css" rel="stylesheet" type="text/css">
  <link href="__PUBLIC__/css/admin/zh-cn-system.css" rel="stylesheet" type="text/css">
  <link href="__PUBLIC__/css/admin/table_form.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/admin/style/zh-cn-styles1.css" title="styles1" media="screen">
  <link rel="alternate stylesheet" type="text/css" href="__PUBLIC__/css/admin/style/zh-cn-styles2.css" title="styles2" media="screen">
  <link rel="alternate stylesheet" type="text/css" href="__PUBLIC__/css/admin/style/zh-cn-styles3.css" title="styles3" media="screen">
  <link rel="alternate stylesheet" type="text/css" href="__PUBLIC__/css/admin/style/zh-cn-styles4.css" title="styles4" media="screen">
  <script type="text/javascript" src="__PUBLIC__/js/admin/jquery.min.js"></script>
  <script type="text/javascript" src="__PUBLIC__/js/admin/jquery.cookie.js"></script>
  <script type="text/javascript" src="__PUBLIC__/js/admin/styleswitch.js"></script>
  <script type="text/javascript" src="__PUBLIC__/js/admin/admin_common.js"></script>
  <script language="javascript" type="text/javascript" src="__PUBLIC__/js/My97DatePicker/WdatePicker.js"></script>
</head>
 <style type="text/css">
    html{
        _overflow-y:scroll
    }
     #search{
        margin: 20px;
     }
    #ord{

        margin: 20px;
        margin-left: 20px;
    }
    table{
        width:100%;
        margin: auto;
        text-align: center;
        background: #fff;
    }
    th{
        background:rgb(18,162,225);
        color: #fff;
        border:solid 1px #fff;
    }
    td{
        background: #ccc;
        border:solid 1px #fff;
    }
</style>
<body>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <p>运单列表</p>
    </div>
</div>
<script type="text/javascript">
    var idTmr;
    function  getExplorer() {
        var explorer = window.navigator.userAgent ;
        //ie
        if (explorer.indexOf("MSIE") >= 0) {
            return 'ie';
        }
        //firefox
        else if (explorer.indexOf("Firefox") >= 0) {
            return 'Firefox';
        }
        //Chrome
        else if(explorer.indexOf("Chrome") >= 0){
            return 'Chrome';
        }
        //Opera
        else if(explorer.indexOf("Opera") >= 0){
            return 'Opera';
        }
        //Safari
        else if(explorer.indexOf("Safari") >= 0){
            return 'Safari';
        }
    }
    function method1(tableid) {//整个表格拷贝到EXCEL中
        if(getExplorer()=='ie')
        {
            var curTbl = document.getElementById(tableid);
            var oXL = new ActiveXObject("Excel.Application");

            //创建AX对象excel
            var oWB = oXL.Workbooks.Add();
            //获取workbook对象
            var xlsheet = oWB.Worksheets(1);
            //激活当前sheet
            var sel = document.body.createTextRange();
            sel.moveToElementText(curTbl);
            //把表格中的内容移到TextRange中
            sel.select();
            //全选TextRange中内容
            sel.execCommand("Copy");
            //复制TextRange中内容
            xlsheet.Paste();
            //粘贴到活动的EXCEL中
            oXL.Visible = true;
            //设置excel可见属性

            try {
                var fname = oXL.Application.GetSaveAsFilename("Excel.xls", "Excel Spreadsheets (*.xls), *.xls");
            } catch (e) {
                print("Nested catch caught " + e);
            } finally {
                oWB.SaveAs(fname);

                oWB.Close(savechanges = false);
                //xls.visible = false;
                oXL.Quit();
                oXL = null;
                //结束excel进程，退出完成
                //window.setInterval("Cleanup();",1);
                idTmr = window.setInterval("Cleanup();", 1);

            }

        }
        else
        {
            tableToExcel('ta');
        }
    }
    function Cleanup() {
        window.clearInterval(idTmr);
        CollectGarbage();
    }
    var tableToExcel = (function() {
        var uri = 'data:application/vnd.ms-excel;base64,',
                template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
                base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) },
                format = function(s, c) {
                    return s.replace(/{(\w+)}/g,
                            function(m, p) { return c[p]; }) }
        return function(table, name) {
            if (!table.nodeType) table = document.getElementById(table)
            var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
            window.location.href = uri + base64(format(template, ctx))
        }
    })();
</script>


<div class="pad-lr-10 table-list">
      <div id="search">
          <form action="__MODULE__/order/search" method="post">
          运单号：<input type="search" name="way" id="way" value="" placeholder="运单号"/>
          时间：
          <input id="date1" class="Wdate" type="text" name="date1" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'date1\')||\'9999-12-31\'}'})"/>
          <input type="submit" name="submit"  value="搜索" style="width: 80px;"/>
          </form>
      </div>
    <button onclick="javascript:method1('ta')">导出EXCEL表</button>
      <form name="myform" id="myform" action="" method="post">
          <div id="ord">
              <table cellspacing="1" id = "ta">
                  <tr>
                      <th rowspan="2">下单时间</th>
                      <th rowspan="2">渠道</th>
                      <th rowspan="2">运单号</th>
                      <th rowspan="2">内单号</th><!--添加-->
                      <th rowspan="2">国际单号</th>
                      <th rowspan="2">目的国</th>
                      <th rowspan="2">品名</th>
                      <th rowspan="2">包裹件数</th>
                      <th rowspan="2">计费重量(kg)</th>
                      <th colspan="3">体积</th><!--添加-->
                      <th rowspan="2">结算费用(￥)</th>
                      <th rowspan="2">是否付款</th>
                      <th rowspan="2">备注</th><!--添加-->
                      <th rowspan="2">用户名</th>
                      <th rowspan="2">实收费用</th><!---->
                      <th rowspan="2">欠费用</th><!---->
                      <th rowspan="2">服务商</th><!---->
                      <th rowspan="2">交货渠道</th><!---->
                      <th rowspan="2">交货金额</th><!---->
                      <th rowspan="2">交货实重</th><!---->
                      <th rowspan="2">订单状态</th><!---->
                      <th rowspan="2">操作</th>
                  </tr>
                  <tr>
                      <th>长</th>
                      <th>宽</th>
                      <th>高</th>
                  </tr>
                  <foreach name="data" item="value">
                      <tr>
                          <td><!--{$value['ord_time']}--></td>
                          <td><!--{$value['company']}--></td>
                          <td><!--{$value['way']}--></td>
                          <td class="dbclick" field="inside_no"><!--{$value['inside_no']}--></td>
                          <if condition="$value['transit'] == false">
                              <td class="dbclick" field="transit">未转运</td>
                              <else/>
                              <td class="dbclick" field="transit"><!--{$value['transit']}--></td>
                          </if>
                          <td><!--{$value['cname']}-->&nbsp;&nbsp;<!--{$value['ename']}--></td>
                          <td class="dbclick" field="g_cname"><!--{$value['g_cname']}--></td>
                          <td class="dbclick" field="piece_num"><!--{$value['piece_num']}--></td>
                          <td class="dbclick" field="weight"><!--{$value['weight']}--></td>
                          <td colspan="3" class="dbclick" field=""><!--{$value['volume']}--></td>
                          <td><!--{$value['money']}--></td>
                          <if condition="$value['ord_status']==0">
                              <td><span>未付款&nbsp;&nbsp;</span> <a href="javascript:;void(0);" onclick="queren(<!--{$value['order_id']}-->);" class="fb button blue " > 确认付款</a></td>
                              <else />
                              <td>已付款</td>
                          </if>
                          <td class="dbclick" field="remarks"><!--{$value['remarks']}--></td>
                          <td><!--{$value['account']}--></td>
                          <td class="dbclick" field="charge'"><!--{$value['charge']}--></td>
                          <td class="dbclick" field="due_expense"><!--{$value['due_expense']}--></td>
                          <td class="dbclick" field="facilitator"><!--{$value['facilitator']}--></td>
                          <td class="dbclick" field="delivery_channel"> <!--{$value['delivery_channel']}--></td>
                          <td class="dbclick" field="delivery_value"><!--{$value['delivery_value']}--></td>
                          <td class="dbclick" field="delivery_weight"><!--{$value['delivery_weight']}--></td>
                          <td class="dbclick" field="statu"><!--{$value['statu']}--></td>
                          <td>
                              <if condition="$value['cancel']==1">
                                  <s>订单已取消</s>
                              <else/>
                              <if condition="$value['ord_status']==1">
                                  <a href="__MODULE__/order/ord_print/nid/<!--{$value['order_id']}-->">打印发票</a>|
                                  <a href="javascript:void(0);" style="text-decoration:line-through" title="已付款不能修改">修改</a> |
                                  <a href="javascript:void(0);" style="text-decoration:line-through;" title="已付款不能取消">取消</a>
                              <else/>
                                <a href="__MODULE__/order/ord_print/nid/<!--{$value['order_id']}-->">打印发票</a>|
                                <a href="__MODULE__/Order/edit/nid/<!--{$value['order_id']}-->" class="edit">修改</a> |
                                <a onclick="return ConfirmDel();" href="__MODULE__/Order/del/nid/<!--{$value['order_id']}-->">取消</a>
                              </if>
                              </if>
                          </td>
                      </tr>
                  </foreach>
                  <tr>
                      <td colspan="24"><!--{$page}--></td>
                  </tr>
              </table>
          </div>
      </form>
    </div>
<script type="text/javascript">
    $("td.dbclick").dblclick(function(){
        var td= $(this);
        var txt = td.text();
        var fie =td.attr("field");
        var input = $("<input style='width:100px;height;10px;'type='text' value='"+txt+"'/>");
        td.html(input);
        input.click(function() { return false; });
        //获取焦点
        input.trigger("focus");
        input.blur(function() {
            var newtxt = $(this).val();
            //判断文本有没有修改
            if (newtxt != txt) {
                td.html(newtxt);
                var url=td.parent().last().find(".edit").attr("href");
                if(url==false){
                    alert("已付款或已取消运单不能修改");
                    td.html(txt);
                    return false;
                }else{
                    var url=url.replace(/edit/,'dbl_click');
                    $.getJSON(url,{fie:fie,value:newtxt},function(msg){})
                }
            }else{
                td.html(txt);
            }
        })
    })
</script>
<script type="text/javascript">
    function queren(t){
        if(confirm("确认已付款吗")){
            $.getJSON("__MODULE__/Order/affirm",{ord_status:1,nid:t},function(msg){
                if(msg){
                    document.location.href="__MODULE__/Order";
                }else{
                    alert("确认失败");
                }
            })
        }
    }
</script>

  </body>
  </html>


